home *** CD-ROM | disk | FTP | other *** search
- { ********************************************************************* }
- { KEYWORD }
- { }
- { Copyright 1989 by Gil Yoder }
- { P.O. Box 307 }
- { Coalgate, OK 74538 }
- { }
- { CIS#: 73237,3103 }
- { }
- { You may use, copy, distribute, and modify KEYWORD without restriction }
- { but you may not sell KEYWORD or programs derived herefrom. If you do }
- { modify the program, the author of KEYWORD would appreciate notifica- }
- { tion. }
- { ********************************************************************* }
- { KEYWORD is a simple program that reports the word values of any key }
- { you press. Simple run the program from the command line and press }
- { keys. If the key is a printable character the key will be displayed. }
- { In any case the value of the key will be displayed in hexadecimal. }
- { To exit from the program press the escape key. }
- { ********************************************************************* }
- { KEYWORD requires Turbo Professional Toolbox from Turbo Power in order }
- { for it to be recompiled. Compile with TP 5.5. }
- { ********************************************************************* }
-
-
-
- program keyword;
-
-
- (*************************************)
- (* *)
- (* Object Oriented Keyword Program *)
- (* *)
- (*************************************)
-
- uses TpEnhKbd, {Must Comment out TpEnhKbd before using ID}
- TpCrt,Std_CVT,
- TpMacro;
-
- type
-
- keys = object {My first simple object!}
- keyw : word; {Binary key representation}
- keystr : String[4]; {String key representation}
- procedure get; {Method to get a key for the keyboard}
- procedure out; {Method to send KeyStr to Crt}
- function isesc : boolean; {Method to check for Escape key}
- end;
-
-
- (*************************************)
- (* Keys Methods *)
- (*************************************)
-
-
- procedure keys.get;
- var
- i : byte;
- h : word;
- begin
- keyw := readkeyword;
- h := keyw;
- keystr := '';
- repeat
- i := h mod 16;
- if i < 10 then
- keystr := char(i+$30) + keystr
- else
- keystr := char(i+$37) + keystr;
- h := h div 16;
- until h = 0;
- while length(keystr) < 4 do
- keystr := '0'+keystr;
- end;
-
- procedure keys.out;
- var
- ch : char absolute keyw;
- special : boolean;
- s : string;
-
- begin
- write(keystr,' = ');
- keytostring(keyw,s,special);
- writeln(s)
- end;
-
- function keys.isesc : boolean;
- begin
- isesc := keyw = esc_key;
- end;
-
- (******* End of Keys Methods *********)
-
- var
- key : keys; {Instantiate "key" as an object of type "keys"}
-
-
- begin
- repeat
- key.get;
- key.out;
- until key.isesc;
- end.